Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

272
Views
It is necessary that when you click on "block one", the rest of the blocks are closed, how to release this?

i need that when I click on one block, it opens an input (already implemented), and another block get closed, please help. Here is my code: i've already realized onClick input appearing, but cant handle with other

function App() {
const [isChecked, setIsChecked] = useState(false)
const [isClosed, setIsClosed] = useState(false)

const handleCheck = () => {
    setIsChecked(isChecked => !isChecked)
}
const handleClose = () => {
    setIsClosed(isClosed => !isClosed)
}

return (

<div className="App">

    <div onClick={handleCheck}>block one</div>
    {isChecked &&
    <input/>
    }
    <div onClick={handleClose}>block two</div>
    {isClosed &&
    <input/>
    }


</div>

); }

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0


import { useState } from "react"
export default function App() {
  const [isChecked, setIsChecked] = useState(false)
  const [isClosed, setIsClosed] = useState(false)
    
    const handleCheck = () => {
      setIsChecked(true)
      setIsClosed(false)
  }
  const handleClose = () => {
      setIsClosed(true)
      setIsChecked(false)
  }
    return(
      <div className="App">

        <div onClick={handleCheck}>block one</div>
        {isChecked &&
        <input/>}
        
        <div onClick={handleClose}>block two</div>
        {isClosed && 
        <input/>}
        


    </div>
    )

}
about 4 years ago · Juan Pablo Isaza Report

0

do this

function App() {
const [isChecked, setIsChecked] = useState(true)
const [isClosed, setIsClosed] = useState(true)

const handleCheck = () => {
    setIsChecked(isChecked => !isChecked)
}
const handleClose = () => {
    setIsClosed(isClosed => !isClosed)
}
return (

<div className="App">

    <div onClick={handleClose}>block one</div>
    {isChecked &&
    <input/>
    }
    <div onClick={handleCheck}>block two</div>
    {  isClosed &&
    <input/>
    }


</div>
); }
about 4 years ago · Juan Pablo Isaza Report

0

I've done my problem by myself. Here is my code:

 import { useState } from "react"
export default function App() {
    const [isChecked, setIsChecked] = useState(false)
    const [isClosed, setIsClosed] = useState(false)

    const handleCheck = () => {
        setIsChecked(isChecked => !isChecked)
    }
    const handleClose = () => {
        setIsClosed(isClosed => !isClosed)
    }
    return(
        <div className="App">
            {
                isClosed ? null : <div onClick={handleCheck}>block one</div>
            }
            {isChecked &&
            <input/>}
            {
                isChecked ? null : <div onClick={handleClose}>block two</div>
            }
            {isClosed &&
            <input/>
            }



        </div>
    )

}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!